<html>
<head><meta charset="utf-8"><title>Statically linking MUSL + C++ · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html">Statically linking MUSL + C++</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212409536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Statically%20linking%20MUSL%20%2B%20C%2B%2B/near/212409536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html#212409536">(Oct 06 2020 at 10:39)</a>:</h4>
<p>We're currently running into <a href="https://github.com/rust-lang/rust/issues/36710">#36710</a>, and I'd like to get a proper fix into rustc if that's possible.</p>
<p>This was attempted in <a href="https://github.com/rust-lang/rust/issues/50105">#50105</a> before, but that caused <a href="https://github.com/rust-lang/rust/pull/50105#issuecomment-388630750">regressions</a>. Most of that PR made it in later, but the <a href="https://github.com/rust-lang/rust/commit/6d9154a830dd9773fe8a4e34e1fc3dfb1ca6f935">commit that fixes the issue</a> and caused the regression didn't. My understanding is that it adds a new dependency on libgcc, or some other implementation of the Itanium C++ ABI, and those might not always be present (they will be if C++ code is involved, but the attempted fix depends on them in any case).</p>
<p>Not sure who knows best what a proper fix here would look like, maybe <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span>, since you recently did some work on musl linkage IIRC?</p>



<a name="212477296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Statically%20linking%20MUSL%20%2B%20C%2B%2B/near/212477296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html#212477296">(Oct 06 2020 at 19:59)</a>:</h4>
<p>See <a href="https://github.com/rust-lang/rust/issues/47551#issuecomment-697138327">https://github.com/rust-lang/rust/issues/47551#issuecomment-697138327</a> and below.</p>



<a name="212477475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Statically%20linking%20MUSL%20%2B%20C%2B%2B/near/212477475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html#212477475">(Oct 06 2020 at 20:00)</a>:</h4>
<p>The immediately working solution is to use <code>-C link-self-contained=no</code> and a native musl toolchain instead of the bits shipped with Rust.</p>



<a name="212477587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Statically%20linking%20MUSL%20%2B%20C%2B%2B/near/212477587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html#212477587">(Oct 06 2020 at 20:01)</a>:</h4>
<p>Improvements to self-contained mode (which are very much similar to <a href="https://github.com/rust-lang/rust/pull/50105">https://github.com/rust-lang/rust/pull/50105</a>) are discussed in comments below.</p>



<a name="212479533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Statically%20linking%20MUSL%20%2B%20C%2B%2B/near/212479533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Statically.20linking.20MUSL.20.2B.20C.2B.2B.html#212479533">(Oct 06 2020 at 20:15)</a>:</h4>
<p>Nice, thanks for the pointers!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>